package com.pandora.credit.mongo.dao.impl;

import com.pandora.credit.mongo.dao.MongoCreditDao;
import com.pandora.credit.mongo.entity.MongoCredit;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author developer
 */
@Repository("mongoCreditDaoImpl")
public class MongoCreditDaoImpl implements MongoCreditDao {
    @Resource
    private MongoTemplate mongoTemplatePc;

    @Override
    public List<MongoCredit> selectAll() {
        List<MongoCredit> li = mongoTemplatePc.findAll(MongoCredit.class);
        return li;
    }

    @Override
    public List<MongoCredit> selectById(List<Long> ids) {
        Query query = new Query();
        query.addCriteria(Criteria.where("_id").in(ids));
        return mongoTemplatePc.find(query, MongoCredit.class);
    }
}
